package top.forlenet.controller;



import top.forlenet.common.CommonConstants;
import top.forlenet.common.CommonResult;
import top.forlenet.entity.User;
import top.forlenet.service.SignService;
import top.forlenet.service.impl.SignServiceImpl;
import top.forlenet.utils.JsonUtils;
import top.forlenet.vo.SignVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "SignListServlet", value = "/list")
public class SignListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        User loginUser = (User) request.getSession().getAttribute(CommonConstants.LOGIN_USER);

        SignService signService = new SignServiceImpl();
        List<SignVO> signVOS = signService.listSignInfo(loginUser.getId());

        response.getWriter().write(JsonUtils.bean2json(CommonResult.success(signVOS)));

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
